package com.kexinde.wjifen.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;

/**
 * 
 * @author wei
 * 
 * 普通用户
 *
 */
@Entity
public class NormalUser {

	private long id;  //  标识（主键）
	private String userName;  // 用户名
	private String password;  // 密码
	private String phone;  // 手机号
	private String selfWord;  // 个性口令
	private List<Address> addresses = new ArrayList<Address>();  // 地址
	private String email;  // 邮箱
	private int purview = 2;  // 权限
	private String imagePath;  // 头像
	private List<ShopPoint> shopPoints = new ArrayList<ShopPoint>();  // 店铺积分
	private long totalPoint;  // 总积分
	private List<ExchangeLog> exchangeLogs = new ArrayList<ExchangeLog>();  // 兑换记录
	private List<ConsumptionRecord> consumptionRecords = new ArrayList<ConsumptionRecord>(); // 消费记录
	
	public NormalUser(){}

	@Id
	@GeneratedValue
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getSelfWord() {
		return selfWord;
	}

	public void setSelfWord(String selfWord) {
		this.selfWord = selfWord;
	}

	@OneToMany(cascade=CascadeType.ALL)
	public List<Address> getAddresses() {
		return addresses;
	}

	public void setAddresses(List<Address> addresses) {
		this.addresses = addresses;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public int getPurview() {
		return purview;
	}

	public void setPurview(int purview) {
		this.purview = purview;
	}

	public String getImagePath() {
		return imagePath;
	}

	public void setImagePath(String imagePath) {
		this.imagePath = imagePath;
	}

	@OneToMany(mappedBy="normalUser",cascade=CascadeType.ALL)
	public List<ShopPoint> getShopPoints() {
		return shopPoints;
	}

	public void setShopPoints(List<ShopPoint> shopPoints) {
		this.shopPoints = shopPoints;
	}

	public long getTotalPoint() {
		return totalPoint;
	}

	public void setTotalPoint(long totalPoint) {
		this.totalPoint = totalPoint;
	}

	@OneToMany(mappedBy="normalUser",cascade=CascadeType.ALL)
	public List<ExchangeLog> getExchangeLogs() {
		return exchangeLogs;
	}

	public void setExchangeLogs(List<ExchangeLog> exchangeLogs) {
		this.exchangeLogs = exchangeLogs;
	}

	@OneToMany(mappedBy="normalUser",cascade=CascadeType.ALL)
	public List<ConsumptionRecord> getConsumptionRecords() {
		return consumptionRecords;
	}

	public void setConsumptionRecords(List<ConsumptionRecord> consumptionRecords) {
		this.consumptionRecords = consumptionRecords;
	}

	@Override
	public String toString() {
		return "NormalUser [id=" + id + ", userName=" + userName
				+ ", password=" + password + ", phone=" + phone + ", selfWord="
				+ selfWord + ", addresses=" + addresses + ", email=" + email
				+ ", purview=" + purview + ", imagePath=" + imagePath
				+ ", shopPoints=" + shopPoints + ", totalPoint=" + totalPoint
				+ ", exchangeLogs=" + exchangeLogs + ", consumptionRecords="
				+ consumptionRecords + "]";
	}
	
}
